<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Checkout_handler
{
	function __construct() {
		$this->CI = get_instance();
		$this->CI->load->library('cart');
	}
	
	public function get_products_in_cart() {
		$this->CI->load->model('produkter');
		$items = $this->CI->cart->contents();
		$products = array();
		foreach($items as $item) {
			$obj = new StdClass();
			$obj->{'product'} = $this->CI->produkter->getProduct(str_replace('prod_', '', $item['id']));
			$obj->{'quantity'} = $item['qty'];
			$products[] = $obj;
			/*
			array_push($products, array(
				'product' => $this->CI->produkter->getProduct(str_replace('prod_', '', $item['id'])),
				'quantity' => $item['qty'],
				)
			);*/
		}
		
		return $products;
	}
}